package ntancnit.app.database;

import android.content.Context;
import android.database.Cursor;
import android.util.Log;

public class GetUserName {
	private Context context;
	
	public GetUserName(Context context){
		this.context = context;
	}
	
	public Boolean isValidData(){
		Boolean isValid = false;
		User user = new User(context);
		Cursor c = user.SelectFromChat();
		if(c != null)
			if(c.moveToFirst()){
				isValid = true;
			}
		c.close();
		user.close();
		return isValid;
	}
	

	public String getUserName(){
		String name = "";
		User user = new User(context);
		Cursor c = user.SelectFromChat();
		if(c != null)
			if(c.moveToFirst()){
				name = c.getString(c.getColumnIndexOrThrow("name"));
				Log.w("ntancnit.app.whereareyou",name);
			}
		c.close();
		user.close();
		return name;
	}
	
	public void insertUser(String name){
		User user = new User(context);
		user.InsertToUser(name);
		user.close();
	}
	
	public void deleteUser(){
		User user = new User(context);
		user.deleteFromEvent("name");
		user.close();
	}
	

}
